package com.ruoyi.salary.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.salary.domain.HrSocialSecurityFund;
import com.ruoyi.salary.service.IHrSocialSecurityFundService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社保公积金Controller
 * 
 * @author gy
 * @date 2025-05-21
 */
@RestController
@RequestMapping("/salary/fund")
public class HrSocialSecurityFundController extends BaseController
{
    @Autowired
    private IHrSocialSecurityFundService hrSocialSecurityFundService;

    /**
     * 查询社保公积金列表
     */
    @PreAuthorize("@ss.hasPermi('salary:fund:list')")
    @GetMapping("/list")
    public TableDataInfo list(HrSocialSecurityFund hrSocialSecurityFund)
    {
        startPage();
        List<HrSocialSecurityFund> list = hrSocialSecurityFundService.selectHrSocialSecurityFundList(hrSocialSecurityFund);
        return getDataTable(list);
    }

    /**
     * 导出社保公积金列表
     */
    @PreAuthorize("@ss.hasPermi('salary:fund:export')")
    @Log(title = "社保公积金", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HrSocialSecurityFund hrSocialSecurityFund)
    {
        List<HrSocialSecurityFund> list = hrSocialSecurityFundService.selectHrSocialSecurityFundList(hrSocialSecurityFund);
        ExcelUtil<HrSocialSecurityFund> util = new ExcelUtil<HrSocialSecurityFund>(HrSocialSecurityFund.class);
        util.exportExcel(response, list, "社保公积金数据");
    }

    /**
     * 获取社保公积金详细信息
     */
    @PreAuthorize("@ss.hasPermi('salary:fund:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hrSocialSecurityFundService.selectHrSocialSecurityFundById(id));
    }

    /**
     * 新增社保公积金
     */
    @PreAuthorize("@ss.hasPermi('salary:fund:add')")
    @Log(title = "社保公积金", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HrSocialSecurityFund hrSocialSecurityFund)
    {
        return toAjax(hrSocialSecurityFundService.insertHrSocialSecurityFund(hrSocialSecurityFund));
    }

    /**
     * 修改社保公积金
     */
    @PreAuthorize("@ss.hasPermi('salary:fund:edit')")
    @Log(title = "社保公积金", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HrSocialSecurityFund hrSocialSecurityFund)
    {
        return toAjax(hrSocialSecurityFundService.updateHrSocialSecurityFund(hrSocialSecurityFund));
    }

    /**
     * 删除社保公积金
     */
    @PreAuthorize("@ss.hasPermi('salary:fund:remove')")
    @Log(title = "社保公积金", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hrSocialSecurityFundService.deleteHrSocialSecurityFundByIds(ids));
    }
}
